<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>用户管理</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8">
        <link href="../../css/mine.css" type="text/css" rel="stylesheet">
        <script type="text/javascript" src="/subject_war_exploded/js/jquery-1.8.0.min.js"></script>
        <script type="text/javascript">
            // 当元素的值发生改变时，会发生 change 事件。
            $(function () {
                $("#dept").change(function () {
                    //1、获取被选中的value
                    var did=$(this).val();
                    if(did==-1){
                        alert("请选择部门");
                    }else {
                        $.ajax({
                            url:"/subject_war_exploded/getroles",
                            data:"did="+did,
                            type:"post",
                            dataType:"json",
                            success:function (rs) {    //rs用来接收返回的结果
                                for(var i=0;i<rs.length;i++){
                                    ///让下拉框的长度为0，也就是rs的长度为0
                                    $("#role")[0].length=0;
                                    //此处是定位到这个add.jsp页面里的角色对象（var role= $("#role");），之后点出add方法，
                                    //此处的[0]是因为add方法为js的方法，所以得把得到的jquery对象化为js对象，加个[0]就OK
                                    // 为下拉框添加元素
                                    //Option(显示到标签对中的值，value值)
                                    $("#role")[0].add(new Option(rs[i].rname,rs[i].roleid));

                                }

                            }
                        })
                    }
                })
            })
        </script>
    </head>

    <body>

        <div class="div_head">
            <span>
                <span style="float:left">当前位置是：-》资源管理》用户管理</span>
                <span style="float:right;margin-right: 8px;font-weight: bold">
                    <a style="text-decoration: none" href="list.jsp">【返回】</a>
                </span>
            </span>
        </div>
        <div></div>

        <div style="font-size: 13px;margin: 10px 5px">
<%--            文件上传时候才会用这enctype="multipart/form-data"--%>
            <form action="/subject_war_exploded/resource/demo2/insertEmp" method="post" >
            <table border="1" width="100%" class="table_a">
                <tr>
                    <td width="120px;">用户编号<span style="color:red">*</span>：</td>
                    <td><input type="text" name="employeenum" value="201501010" /></td>
                </tr>
                <tr>
                    <td>登录账号<span style="color:red">*</span>：</td>
                    <td>
                       <input type="text" name="loginname" value="zhangsan" />
                    </td>
                </tr>
               
                <tr>
                    <td>用户姓名<span style="color:red">*</span>：</td>
                    <td>
						<input type="text0" name="username" value="张三" /></td>
                </tr>
                <tr>
                    <td>密码<span style="color:red">*</span>：</td>
                    <td>
						<input type="text"  name="loginpassword" value="......" />
					</td>
                </tr>

                <tr>
                    <td>所属部门<span style="color:red">*</span>：</td>
                    <td>

                        <select name="deptid" id="dept">
                            <option value="-1">请选择</option>
                            <c:forEach items="${dlist}" var="dept">
                                <option value="${dept.deptid}">${dept.deptname}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td>所属职位<span style="color:red">*</span>：</td>
                    <td>
                        
						<select id="role" name="roleid">
							<option value="-1">请选择</option>
						</select>
                    </td>
                </tr>


				<tr>
                    <td>身份证<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="idcaid" value="372902198708084567" />
                    </td>                
                </tr>

				<tr>
                    <td>联系电话<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="telphone" value="17718181920"/>
                    </td>                
                </tr>

				<tr>
                    <td>邮箱<span style="color:red">*</span>：</td>
                    <td>
                        <input type="text" name="email" value="AAA@163.com" />
                    </td>                
                </tr>

				<tr>
                    <td>联系地址：</td>
                    <td>
                        <input type="text" name="address" value="海淀区软件园孵化器" />
                    </td>                
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" value="添加">
						<input type="reset" value="清空">
                    </td>
                </tr>  
            </table>
            </form>
        </div>
    </body>
</html>